package com.briup.smartlabs.web.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.briup.smartlabs.bean.SmartLabs;
import com.briup.smartlabs.common.utils.Response;
import com.briup.smartlabs.service.LabsService;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(tags = "实验室信息服务")
@RestController
@RequestMapping("/labs")
public class LabsController {
	
	@Autowired
	private LabsService labsService;
	
		@GetMapping("/by/condition")
	public Response<PageInfo<SmartLabs>> findByCondition(
		int pageNum, int pageSize,String key){
		PageInfo<SmartLabs> page = 
				labsService.findByCondition(pageNum,pageSize,key);
		return Response.ok(page);
	}
	
	
	@DeleteMapping("/batch")
	public Response<Map<String, List<String>>> removeByBatch(
			@RequestParam(name = "ids")List<String> ids){
		Map<String,List<String>> result = 
				labsService.removeByBatch(ids);
		return Response.ok(result);
	}
	

	@PostMapping("/lab")
	public Response<String> saveOrUpdate(
			@RequestBody SmartLabs labs){

		labsService.saveOrUpdate(labs);
		return Response.ok("操作成功");
	}
}









